/*
@ auth	hdg
@ email	  hdg1988@gmail.com
@ date	2010-3-26
	index页面js配置
*/
$(document).ready(function(){
	var quickMenu = new quickMenu_FUN();
	quickMenu.renderTo="normalQuickMenu";
	quickMenu.reg([{
			key:'IE8',
			desc:"IE8浏览器",
			show:true,
			title:"IE浏览器",
			imgSrc:'image/ie8.png',
			cmd:function(event){
				alert('IE8浏览器');
			}
		},{
			key:'editplus',
			desc:"editplus编辑器",
			show:false,
			title:"editplus编辑器",
			imgSrc:'image/editplus.png',
			cmd:function(event){
				alert('editplus编辑器');
			}
		},{
			key:'book_open',
			desc:"book_open",
			show:false,
			title:"book_open",
			imgSrc:'image/book_open.png',
			cmd:function(event){
				alert('book_open');
			}
		},{
			key:'Firefox',
			desc:"menu2",
			show:true,
			title:"FireFox浏览器",
			imgSrc:'image/firefox.png',
			cmd:function(event){
				alert("FireFox浏览器");
			}
		}]);



		// 底部右边按钮
		var processMenu=new processMenu_FUN();
		processMenu.renderTo="process_menu";
		processMenu.reg([{
			key:'sound',
			show:false,
			title:"音量",
			imgSrc:'image/sound.png',
			cmd:function(event){
				alert("音量");
			}
		},{
			key:'local_link',
			show:true,
			title:"本地连接",
			imgSrc:'image/local_link_1.png',
			cmd:function(event){
				alert("本地连接");
			}
		},{
			key:'QQ',
			show:false,
			title:"腾讯QQ",
			imgSrc:'image/QQ.png',
			cmd:function(event){
				alert("腾讯QQ");
			}
		},{
			key:'360safe',
			show:true,
			title:"360安全卫士",
			imgSrc:'image/360safe.png',
			cmd:function(event){
				alert("360安全卫士");
			}
		},{
			key:'window_safe',
			show:true,
			title:"windows 防火墙",
			imgSrc:'image/window_safe.png',
			cmd:function(event){
				alert("windows 防火墙");
			}
		}]);


		// 开始菜单
		var startMenu=new startMenu_FUN();
		startMenu.renderTo="bottom_bar_start";
		startMenu.reg([{
			key:'my_doc',
			desc:'我的文档',
			title:'我的文档',
			position:'right',
			imgSrc:'image/my_documents.png',
			cmd:function(){
				alert("我的文档")
			}
		},{
			key:'my_pic',
			desc:'图片收藏',
			title:'图片收藏',
			position:'right',
			imgSrc:'image/my_pictures.png',
			cmd:function(){
				alert("图片收藏")
			}
		},{
			key:'my_music',
			desc:'我的音乐',
			title:'我的音乐',
			position:'right',
			imgSrc:'image/my_musics.png',
			cmd:function(){
				alert("我的音乐")
			}
		},{
			key:'my_computer',
			desc:'我的电脑',
			title:'我的电脑',
			position:'right',
			imgSrc:'image/my_computer.png',
			cmd:function(){
				alert("我的电脑")
			}
		},{
			key:'seperate',
			position:'right'
		},{
			key:'kongzhi_mianbang',
			desc:'控制面板',
			title:'控制面板',
			position:'right',
			imgSrc:'image/mian_bang.png',
			cmd:function(){
				alert("控制面板")
			}
		},{
			key:'manager_tool',
			desc:'管理工具',
			title:'管理工具',
			position:'right',
			items:manager_tools,
			imgSrc:'image/manager_tool.png',
			cmd:function(){
				alert("管理工具")
			}
		},{
			key:'linkto',
			desc:'连接到',
			title:'连接到',
			position:'right',
			imgSrc:'image/linkto.png',
			cmd:function(){
				alert("连接到")
			}
		},{
			key:'print',
			desc:'打印机和传真',
			title:'打印机和传真',
			position:'right',
			imgSrc:'image/print.png',
			cmd:function(){
				alert("打印机和传真")
			}
		},{
			key:'seperate',
			position:'right'
		},{
			key:'search',
			desc:'搜索',
			title:'搜索',
			position:'right',
			imgSrc:'image/search.png',
			cmd:function(){
				alert("搜索")
			}
		},{
			key:'run',
			desc:'运行 . . .',
			title:'运行 . . .',
			position:'right',
			imgSrc:'image/run.png',
			cmd:function(){
				alert("运行 . . .")
			}
		},{
			key:'IE8',
			desc:'Internet Explorer',
			title:'Internet Explorer浏览器',
			position:'left',
			imgSrc:'image/ie_32x32.png',
			cmd:function(){
			}
		},{
			key:'outlook',
			desc:'Outlook Express电子邮件',
			title:'Outlook Express电子邮件',
			position:'left',
			imgSrc:'image/outlook_32x32.png',
			cmd:function(){
			}
		},{
			key:'seperate',
			position:'left'
		},{
			key:'QQ',
			desc:'腾讯QQ2009',
			title:'腾讯QQ2009',
			position:'left',
			imgSrc:'image/QQ_32x32.png',
			cmd:function(){
			}
		},{
			key:'firefox',
			desc:'firefox浏览器',
			title:'firefox浏览器',
			position:'left',
			imgSrc:'image/firefox_32x32.png',
			cmd:function(){
			}
		},{
			key:'eclipse',
			desc:'eclipse编辑器',
			title:'eclipse编辑器',
			position:'left',
			imgSrc:'image/eclipse.png',
			cmd:function(){
			}
		},{
			key:'flash',
			desc:'Flash CS3 Pro',
			title:'Flash CS3 Pro',
			position:'left',
			imgSrc:'image/flash.png',
			cmd:function(){
			}
		},{
			key:'photoshop',
			desc:'Adobe Photoshop CS2',
			title:'Adobe Photoshop CS2',
			position:'left',
			imgSrc:'image/photoshop.png',
			cmd:function(){
			}
		},{
			key:'allprogram',
			items:allprogram
		}]);

	var context_Menu =new contextMenu();
		context_Menu.reg([{
			key:'sortDesktopMenu',
			desc:'排列图标',
			quickKey:'I',
			items:sortDesktopMenu
		},{
			key:'reflesh',
			desc:'刷新',
			quickKey:'E',
			cmd:function(){
				window.location.reload();
			}
		},{
			key:'seperate'
		},{
			key:'past',
			desc:'粘贴',
			quickKey:'P',
			disabled:true,
			cmd:function(){
				alert("粘贴");
			}
		},{
			key:'past',
			desc:'粘贴快捷方式',
			quickKey:'S',
			disabled:true,
			cmd:function(){
				alert("粘贴");
			}
		},{
			key:'undodelete',
			desc:'撤销删除',
			quickKey:'U',
			disabled:true,
			cmd:function(){
				alert("撤销删除");
			}
		},{
			key:'seperate'
		},{
			key:'nvidia',
			desc:'NVIDIA 控制面板',
			disabled:true,
			cmd:function(){
				alert("NVIDIA 控制面板");
			}
		},{
			key:'seperate'
		},{
			key:'new',
			quickKey:'W',
			desc:'新建',
			items:newBuild
		},{
			key:'seperate'
		},{
			key:'property',
			desc:'属性',
			quickKey:'R',
			cmd:function(){
				alert("属性");
			}
		}]);
		
	windowTaskManager=new windowTaskMenu();
	windowTaskManager.renderTo='windowTaskManager';
	windowTaskManager.reg([]);
		
	//this.oncontextmenu = context_Menu.show();
		//注册按钮结束

		
		//执行事件
		$(window).resize(function(){
			resizeDesktop();
			startMenu.setStyle();
			quickMenu.setStyle();
		});  
		//
		$(document).bind('click',function(){
			startMenu.hide();
			quickMenu.hide();
		});
		
		$(document).bind('mousedown',function(){
			windowTaskManager.removeActiveWin();
		});
		
		$('.desktop_menu').bind('dblclick',function(){
				if($('#'+this.panel+'_panel').get(0)==null){
					windowTaskManager.addMenu([{
							desc:this.desc,
							id:this.panel,
							imgSrc:this.imgSrc
						}]);
					dragresize.apply(document.body);
				}
				windowTaskManager.showWindow('xxx_'+this.panel);
		});
});

var newBuild=[{
			key:'newfolder',
			desc:'文件夹',
			quickKey:'F',
			imgSrc:'image/newfolder.png',
			cmd:function(){
				alert("文件夹");
			}
		},{
			key:'quickmenu',
			desc:'快捷方式',
			quickKey:'S',
			disabled:true,
			imgSrc:'image/quickmenu.png',
			cmd:function(){
				alert("快捷方式");
			}
		},{
				key:'seperate'
		},{
			key:'flashAction',
			disabled:true,
			desc:'Flash ActionScript ',
			imgSrc:'image/flashAction.png',
			cmd:function(){
				alert("Flash ActionScript ");
			}
		},{
			key:'nodebook',
			desc:'文本文档',
			imgSrc:'image/nodebook.png',
			cmd:function(){
				alert("文本文档");
			}
		},{
			key:'word',
			desc:'Microsoft Word 文档',
			imgSrc:'image/word.png',
			cmd:function(){
				alert("文本文档");
			}
		},{
			key:'winrar',
			desc:'WinRAR  档案文件',
			imgSrc:'image/winrar.png',
			cmd:function(){
				alert("WinRar 文件");
			}
		}];
var sortDesktopMenu=[{
			key:'byname',
			desc:'名称',
			quickKey:'N',
			disabled:true,
			cmd:function(){
				alert("名称");
			}
		},{
			key:'bysize',
			desc:'大小',
			quickKey:'S',
			disabled:true,
			cmd:function(){
				alert("大小");
			}
		},{
			key:'byclass',
			desc:'类型',
			quickKey:'T',
			disabled:true,
			cmd:function(){
				alert("类型");
			}
		},{
			key:'bymodifytime',
			desc:'修改时间',
			quickKey:'M',
			disabled:true,
			cmd:function(){
				alert("修改时间");
			}
		},{
			key:'seperate'
		},{
			key:'bygroup',
			desc:'按组排列',
			quickKey:'G',
			disabled:true,
			cmd:function(){
				alert("按组排列");
			}
		},{
			key:'byauto',
			desc:'自动排列',
			quickKey:'A',
			disabled:true,
			cmd:function(){
				alert("自动排列");
			}
		},{
			key:'bylayout',
			desc:'对齐到网络',
			quickKey:'L',
			disabled:true,
			cmd:function(){
				alert("对齐到网络");
			}
		},{
			key:'seperate'
		},{
			key:'showdesktopmenu',
			desc:'显示桌面图标',
			quickKey:'D',
			disabled:true,
			cmd:function(){
				alert("显示桌面图标");
			}
		},{
			key:'lockwebprogram',
			desc:'在桌面上锁定web项目',
			quickKey:'I',
			disabled:true,
			cmd:function(){
				alert("在桌面上锁定web项目");
			}
		}];
		
var manager_tools=[{
			key:'manager_tool_1',
			desc:'本地安全策略',
			title:'本地安全策略',
			imgSrc:'image/manager_tool_1.png',
			cmd:function(event){
					alert("本地安全策略");
				}
			},
			{
			key:'manager_tool_2',
			desc:'服务',
			title:'服务',
			imgSrc:'image/manager_tool_2.png',
			cmd:function(event){
					alert("服务");
				}
			},
			{
			key:'manager_tool_3',
			desc:'计算机管理',
			title:'计算机管理',
			imgSrc:'image/manager_tool_3.png',
			cmd:function(event){
					alert("计算机管理");
				}
			},{
			key:'manager_tool_4',
			desc:'事件查看器',
			title:'事件查看器',
			imgSrc:'image/manager_tool_4.png',
			cmd:function(event){
					alert("事件查看器");
				}
			},{
			key:'manager_tool_5',
			desc:'数据源（ODBC）',
			title:'数据源（ODBC）',
			imgSrc:'image/manager_tool_5.png',
			cmd:function(event){
					alert("数据源（ODBC）");
				}
			},{
			key:'manager_tool_6',
			desc:'性能',
			title:'性能',
			imgSrc:'image/manager_tool_6.png',
			cmd:function(event){
					alert("性能");
				}
			},{
			key:'manager_tool_7',
			desc:'组件服务',
			title:'组件服务',
			imgSrc:'image/manager_tool_7.png',
			cmd:function(event){
					alert("组件服务");
				}
			}]

	/**
			附件菜单
			*/
	var appendix=[{
					key:'appendix_tools',
					desc:'辅助工具',
					title:'辅助工具',
					imgSrc:'image/program_folder.png',
					items:[{
						key:"fadajian",
						desc:"放大镜",
						title:"放大镜",
						imgSrc:''
					}]
				},{
					key:'txt_editor',
					desc:'记事本',
					title:'记事本',
					imgSrc:'image/txt_editor_16x16.png',
					cmd:function(){
						alert("txt_editor")
					}
				}]
	
			
			/*
			所有程序菜单
			*/

		var allprogram=[{
				key:'QQ',
				desc:'QQ2009',
				title:'QQ2009QQ2009',
				imgSrc:'image/qq.png',
				cmd:function(){
					alert("QQ")
				}
			},{
				key:'seperate'
			},{
				key:'adobe',
				desc:'adobe',
				title:'adobe',
				imgSrc:'image/program_folder.png',
				cmd:function(){
					alert("adobe")
				},
				items:[{
					key:'flash',
					desc:'Adobe flash CSS3',
					title:'Adobe flash CSS3 professional',
					imgSrc:'image/flash_16x16.png',
					cmd:function(){
						alert("Adobe flash CSS3 professional")
					}
				},{
					key:'photoshop',
					desc:'Adobe photoshop',
					title:'Adobe photoshop',
					imgSrc:'image/photoshop_16x16.png',
					cmd:function(){
						alert("Adobe photoshop")
					}
				}]
			},{
				key:'apach_tomcat_6',
				desc:'apach tomcat 6.0',
				title:'apach tomcat 6.0',
				imgSrc:'image/program_folder.png',
				cmd:function(){
					alert("apach tomcat 6.0")
				},
				items:[{
					key:'Configure_Tomcat',
					desc:'Configure Tomcat',
					title:'Configure Tomcat',
					imgSrc:'image/tomcat_16x16.png',
					cmd:function(){
						alert("Configure Tomcat")
					}
				},{
					key:'Monitor_Tomcat',
					desc:'Monitor Tomcat',
					title:'Monitor Tomcat',
					imgSrc:'image/tomcat_16x16.png',
					cmd:function(){
						alert("Monitor Tomcat")
					}
				},{
					key:'Uninstall_Tomcat',
					desc:'Uninstall Tomcat 6.0',
					title:'Uninstall Tomcat 6.0',
					imgSrc:'image/tomcat_16x16.png',
					cmd:function(){
						alert("Uninstall Tomcat")
					}
				}]
			},{
				key:'Editplus_3',
				desc:'Editplus 3',
				title:'Editplus 3',
				imgSrc:'image/program_folder.png',
				cmd:function(){
					alert("Editplus 3")
				},
				items:[{
					key:'editplus',
					desc:'run editplus 3',
					title:'run editplus 3',
					imgSrc:'image/editplus_16x16.png',
					cmd:function(){
						alert("run editplus 3")
					}
				},{
					key:'uninstall_editplus',
					desc:'uninstall editplus 3',
					title:'uninstall editplus 3',
					imgSrc:'image/editplus_16x16.png',
					cmd:function(){
						alert("uninstall editplus 3")
					}
				}]
			},{
				key:'Macromedia',
				desc:'Macromedia',
				title:'Macromedia',
				imgSrc:'image/program_folder.png',
				cmd:function(){
					alert("Macromedia")
				},
				items:[{
					key:'macromedia_extension',
					desc:'macromedia extension',
					title:'macromedia extension',
					imgSrc:'image/macromedia_extension_16x16.png',
					cmd:function(){
						alert("macromedia extension")
					}
				},{
					key:'macromedia_flash',
					desc:'macromedia flash 8',
					title:'macromedia flash 8',
					imgSrc:'image/macromedia_flash_16x16.png',
					cmd:function(){
						alert("macromedia flash 8")
					}
				},{
					key:'macromedia_flash_video',
					desc:'macromedia flash video 8',
					title:'macromedia flash video 8',
					imgSrc:'image/macromedia_flash_video_16x16.png',
					cmd:function(){
						alert("macromedia flash video 8")
					}
				}]
			},{
				key:'Microsoft_Office',
				desc:'Microsoft Office',
				title:'Microsoft Office',
				imgSrc:'image/program_folder.png',
				cmd:function(){
					alert("Microsoft Office")
				},
				items:[{
					key:'office_word',
					desc:'Microsoft Office word 2003',
					title:'Microsoft Office word 2003',
					imgSrc:'image/office_word_16x16.png',
					cmd:function(){
						alert("Microsoft Office word 2003")
					}
				},{
					key:'office_excel',
					desc:'Microsoft Office excel 2003',
					title:'Microsoft Office excel 2003',
					imgSrc:'image/office_excel_16x16.png',
					cmd:function(){
						alert("Microsoft Office excel 2003")
					}
				},{
					key:'office_powerpoint',
					desc:'Microsoft Office powerpoint 2003',
					title:'Microsoft Office powerpoint 2003',
					imgSrc:'image/office_powerpoint_16x16.png',
					cmd:function(){
						alert("Microsoft Office powerpoint 2003")
					}
				}]
			},{
				key:'Myeclipse_7',
				desc:'Myeclipse 7.0 ',
				title:'Myeclipse 7.0 ',
				imgSrc:'image/program_folder.png',
				cmd:function(){
					alert("Myeclipse 7.0 ")
				},
				items:[{
					key:'myeclipse',
					desc:'MyEclipse 7.0',
					title:'MyEclipse 7.0',
					imgSrc:'image/myeclipse_16x16.png',
					cmd:function(){
						alert("MyEclipse 7.0")
					}
				},{
					key:'uninstall',
					desc:'Uninstall MyEclipse 7.0',
					title:'Uninstall MyEclipse 7.0',
					imgSrc:'image/uninstall_16x16.png',
					cmd:function(){
						alert("Uninstall MyEclipse 7.0")
					}
				}]
			},{
				key:'Unlocker',
				desc:'Unlocker',
				title:'Unlocker',
				imgSrc:'image/program_folder.png',
				items:[{
					key:'null',
					desc:'(空)',
					title:'(空)',
					imgSrc:'',
					cmd:function(){
						alert("(空)")
					}
				}],
				cmd:function(){
					alert("Unlocker")
				}
			},{
				key:'appendix',
				desc:'附件',
				title:'附件',
				imgSrc:'image/program_folder.png',
				cmd:function(){
					alert("附件")
				},
				items:appendix
			},{
				key:'autorun',
				desc:'启动',
				title:'启动',
				imgSrc:'image/program_folder.png',
				cmd:function(){
					alert("启动")
				},
				items:[{
					key:'null',
					desc:'(空)',
					title:'(空)',
					imgSrc:'',
					cmd:function(){
						alert("(空)")
					}
				}]
			},{
				key:'Tencent_soft',
				desc:'腾讯软件',
				title:'腾讯软件',
				imgSrc:'image/program_folder.png',
				cmd:function(){
					alert("腾讯软件")
				}
			},{
				key:'IE',
				desc:'Internet Explorer',
				title:'Internet Explorer',
				imgSrc:'image/ie8.png',
				cmd:function(){
					alert("Internet Explorer")
				}
			},{
					key:'txt_editor',
					desc:'记事本',
					title:'记事本',
					imgSrc:'image/txt_editor_16x16.png',
					cmd:function(){
						alert("txt_editor")
					}
			}];
		
//一些页面相关方法
function resizeDesktop(){
	var H = $(window).height()-30;
	H = H>0?H:0;
	$("#desktop").css({
		height:H
	});
	//document.getElementById("desktop").style.height=document.documentElement.clientHeight-30+"px";
}

function initTime(){
		var myDate = new Date();
		var hour = myDate.getHours();
		var minute = myDate.getMinutes();
		var seperate=isIE()?" : ":":";
		if(minute<10)
			minute = "0"+minute;
		if($(".system_time").get(0)==null)
			$("<div class='system_time'>"+hour+seperate+minute+"</div>").appendTo("#bottom_bar_process");
		else
			$(".system_time").html(hour+seperate+minute);
		window.setTimeout("initTime()", 30000);
}

function initLocalLink(){
	var logoNum = parseInt(100*Math.random())%4;
	var time=Math.max(parseInt(5*Math.random()),1);
	$('div[key="local_link"] img').attr('src','image/local_link_'+logoNum+'.png');
	setTimeout(initLocalLink,time*1000);
}
